<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/5/15
  Time: 17:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!--分页标签 -->
<%@ taglib prefix="page" uri="/xianzhiOA/pageTag" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="p" uri="/xianzhiOA/powerTag" %>


<html>
<head>
    <title>申请一览</title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/dist/backEnd/js/jquery-2.1.1.min.js"></script>
    <!--弹出框需要导入的css-->
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/dist/backEnd/css/popup/common.css"/>

    <script type="application/javascript">


        
        window.onload=function () {

            if("${auditStatus}" != null && "${auditStatus}" !=""){
                var auditStatus="${auditStatus}";
                auditStatus=parseInt(auditStatus)+1;
                var all_options = document.getElementById("auditStatus").options;
                all_options[auditStatus].selected=true;
            }
        }



        //分页的事件
        function pToSub(page) {
            if (page != undefined) {
                var pageInp = document.getElementById("page");
                pageInp.value = page;
                var form = document.getElementById("templetBaseInfoForm");
                form.submit();
            }
        }


          function confirmEvent() {
              var obj=document.getElementById("templetBase_div");
              var index = obj.selectedIndex; // 选中索引
             var  value=obj.options[index].value;

            window.location.href="${pageContext.request.contextPath}/XzTempletBaseInfo/structureTemplet.emp?templetBaseId="+value;
          }

          //删除该条请求的事件
          function deleteCheck(templetBaseInfoId) {
              if(confirm("确定要删除吗？")){
              window.location.href="${pageContext.request.contextPath}/XzTempletBaseInfo/deleteEmpletBaseInfo.emp?templetBaseInfoId="+templetBaseInfoId;
              }
          }

        //       弹出框开始
        var w,h,className;
        function getSrceenWH(){
            w = $(window).width();
            h = $(window).height();
            $('#dialogBg').width(w).height(h);

        }

        window.onresize = function(){
            getSrceenWH();
        }

        $(window).resize();

        $(function(){
            getSrceenWH();

            //显示弹框
//            $('.showA').click(function(){
//
//                className = $(this).attr('class');
//                $('#dialogBg').fadeIn(300);
//                $('#dialog').removeAttr('class').addClass('animated '+className+'').fadeIn();
//            });


            //关闭弹窗
            $('.claseDialogBtn').click(function(){
                $('#dialogBg').fadeOut(300,function(){
                    $('#dialog').addClass('bounceOutUp').fadeOut();
                });
            });
        });

        //显示弹框
        function showBox(Selected,templetBaseInfoId) {

            <%--var auditStatus="${auditStatus}";--%>
            <%--auditStatus=parseInt(auditStatus)+1;--%>
            <%--var all_options = document.getElementById("auditStatus").options;--%>
            <%--all_options[auditStatus].selected=true;--%>

            <%--var templetBaseInfoId="${templetBaseInfoId}";--%>


            className = $(this).attr('class');
            $('#dialogBg').fadeIn(300);
            $('#dialog').removeAttr('class').addClass('animated '+className+'').fadeIn();


            Selected=parseInt(Selected);
            var all_options = document.getElementById("box_auditStatus").options;
            all_options[Selected].selected=true;

           document.getElementById("test_input").value=templetBaseInfoId;
        }

      //弹出框的修改状态事件
//        function updateState() {
//           var test_input=document.getElementById("test_input").value;
//            alert("test_input:"+test_input);
//
//        }



        //       弹出框结束

    </script>


</head>
<body>
<!--头部开始-->
<jsp:include page="headerBack.jsp"/>
<!-- 导航 -->
<jsp:include page="leftBack.jsp"/>
<!--内容页-->
<div class="main">

    <!--内容页头部-->
    <div class="page-header">
        <div class="pull-left">
            <ol class="breadcrumb visible-sm visible-md visible-lg">
                <li><a href="two.html"><i class="icon fa fa-home"></i>主页</a></li>
                <li class="active"><i class="fa fa-pencil"></i>基本信息</li>
            </ol>
        </div>
        <div class="pull-right">
            <h2>主页</h2>
        </div>
    </div>
<form method="post" id="templetBaseInfoForm" class="search1">
    <div>
        <div>
            <p:power jspPower="申请管理：添加">
            请选择您申请的模板:
            <select id="templetBase_div">
                <c:forEach items="${templetBaseList}" var="templetBase">
                    <option value="${templetBase.templetBaseId}">${templetBase.templetName}</option>
                </c:forEach>
            </select>
                <button type="button" onclick="confirmEvent()" style="margin-left: 20px" class="three btn btn-primary">确定</button>
            </p:power>
        </div>
        <div style="margin-top: 10px">
            <div style="float: left">
            <input type="text" placeholder="申请名称..." name="templetName" value="${templetBaseInfo.templetName}">
            <input style="width: 200px" class="sang_Calender" name="beginStr" type="text" value="${beginStr}" placeholder="开始时间...">
            <input style="width: 200px" class="sang_Calender" name="endStr" type="text" value="${endStr}" placeholder="结束时间...">
            <select name="auditStatus" id="auditStatus">
                <option value="4">--审核状态--</option>
                <option value="0">审核中</option>
                <option value="1">成功</option>
                <option value="2">驳回</option>
                <option value="3">撤回</option>
            </select>

            <button type="submit" class="one"><span class="fa fa-search"></span></button>
            </div>
            <div>
            <a href="${pageContext.request.contextPath}/XzTempletBaseInfo/choiceBaseTemplet.emp" class="three btn btn-primary">重置</a>
            </div>

        </div>
    </div>
    <div style="clear: both"></div>
    <div>
        <span style="color: red">${msg}</span>
    </div>
    <!--表格-->
    <div class="well" style="margin-top: 20px">
        <input id="page" name="page" type="hidden" value="${page}">
        <input id="pages" name="pages" type="hidden" value="${pages}">
        <table class="table" id="now">
            <thead>
            <tr>
                <th class="d">申请名称</th>
                <th class="d">申请时间</th>
                <th class="d">申请状态</th>
                <c:if test="${userLogin.empRole.equals('1')}">
                    <th class="dd">修改状态</th>
                </c:if>
                <p:power jspPower="申请管理：删除">
                    <th class="d">删除申请</th>
                </p:power>
                <p:power jspPower="申请管理：详情">
                    <th class="dd">详情</th>
                </p:power>
            </tr>
            </thead>
            <tbody>
            <c:forEach var="templetBaseInfo" items="${templetBaseInfoList}">
                <tr>
                    <td>${templetBaseInfo.templetName}</td>
                    <td><fmt:formatDate type="both" value="${templetBaseInfo.applicantTime}" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
                    <td>
                    <c:choose>
                        <c:when test="${templetBaseInfo.auditStatus == 0}">审核中</c:when>
                        <c:when test="${templetBaseInfo.auditStatus == 1}">成功</c:when>
                        <c:when test="${templetBaseInfo.auditStatus == 2}">驳回</c:when>
                        <c:when test="${templetBaseInfo.auditStatus == 3}">撤回</c:when>
                    </c:choose>
                    </td>
                    <c:if test="${userLogin.empRole.equals('1')}">
                    <td>
                        <a  class="showA" onclick="showBox(${templetBaseInfo.auditStatus},${templetBaseInfo.templetBaseInfoId})"><i class="fa fa-pencil"></i></a>
                    </td>
                    </c:if>
                    <p:power jspPower="申请管理：删除">
                    <td><a onclick="deleteCheck(${templetBaseInfo.templetBaseInfoId})" role="button" data-toggle="modal"><i
                            class="fa fa-times"></i></a>
                    </td>
                    </p:power>
                    <p:power jspPower="申请管理：详情">
                      <td>
                          <a href="${pageContext.request.contextPath}/XzTempletBaseInfo/toDetails.emp?templetBaseInfoId=${templetBaseInfo.templetBaseInfoId}"  role="button" data-toggle="modal"><i class="fa fa-file-text"></i></a>
                      </td>
                    </p:power>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>


    <!--分页符-->
    <div style="float: right">
        <ul class="pagination">
            <page:paging length="10" page="${page}" pages="${pages}"/>
        </ul>
    </div>
</form>
</div>

<!--弹出框-->
<div class="box">

    <div id="dialogBg"></div>
    <div id="dialog" class="animated">
        <img class="dialogIco" width="50" height="50" src="${pageContext.request.contextPath}/dist/backEnd/img/popup/ico.png" alt="" />
        <div class="dialogTop">
            <a href="javascript:;" class="claseDialogBtn">关闭</a>
        </div>
        <form action="${pageContext.request.contextPath}/XzTempletBaseInfo/updateState.emp" method="post" id="editForm">
            <ul class="editInfos">

                <li><label><font color="#ff0000">* </font>状态：
                    <select name="auditStatus" id="box_auditStatus">
                        <option value="0">审核中</option>
                        <option value="1">成功</option>
                        <option value="2">驳回</option>
                        <option value="3">撤回</option>
                    </select>

                </label></li>
                <li><button type="submit" class="btn btn-success">确认提交</button></li>
            </ul>
            <input type="hidden" id="test_input" name="templetBaseInfoId"/>
        </form>
    </div>
</div>

<script type="text/javascript" src="${pageContext.request.contextPath}/dist/backEnd/js/datetime.js"></script>
</body>
</html>
